import { BaseService } from './base.service';
import { Injectable } from '@angular/core';
import { PermitItem } from '../models/permitItem';

@Injectable({
  providedIn: 'root'
})
export class PermitService extends BaseService {
  onGetSelectMenus;
  savePermists(permitList: PermitItem[], authObject) {
    let url = 'api/accountpermits';

    url = url + `?authObjectId=${authObject.authObjectId}&authObjectType=${authObject.authObjectType}`;

    return this.post(url, permitList);
  }

  queryAccountPermits(params) {
    let url = 'api/accountpermits';
    return this.get(url, { params });
  }

  getUserPermits(userId: string, accountId: string) {
    let url = `api/user/${userId}/account/${accountId}/accountpermits`;
    return this.get(url);
  }

  updateAccount(account) {
    let url = `api/account`;
    return this.put(url, account);
  }

  getAccountById(accountId: string) {
    let url = `api/account/${accountId}`;
    return this.get(url);
  }

  queryDataRegisterPermits(queryParams: IDataRPermitQueryParams) {
    const url = `api/datarPermits`;
    return this.get(url, { params: queryParams as any });
  }
}

export interface IDataRPermitQueryParams {
  dataRegisterId?: string;
  accountId?: string;
  orgId?: string;
}
